﻿@model HPIT_LiuzuPoint.Entity.ViewModel.GiftEditViewModel

<link href="~/Content/Site.css" rel="stylesheet" type="text/css" />
<link href="~/Content/easyui/default/easyui.css" rel="stylesheet" type="text/css" />
<link href="~/Content/easyui/icon.css" rel="stylesheet" type="text/css" />
<script src="~/Scripts/easyui/jquery-1.11.1.js" type="text/javascript"></script>
<script src="~/Scripts/easyui/jquery-easyui-min.js" type="text/javascript"></script>
<script src="~/Scripts/easyui/easyui-lang-zh_CN.js" type="text/javascript"></script>

@using (Html.BeginForm("Edit", "Gift", FormMethod.Post, new { id = "from_Gift" }))
{
    <fieldset>
        <length>房间基本信息</length>
        <table align="center">
            <tr>
                <td>礼品编号：</td>
                <td>
                    @Html.EditorFor(model => model.EG_GiftCode)
                </td>
            </tr>
            <tr>
                <td>礼品名称：</td>
                <td>@Html.EditorFor(model => model.EG_GiftName, new { htmlAttributes = new { @class = "easyui-validatebox", data_options = "required:true" } })</td>
            </tr>
            <tr>
                <td>礼品图片：</td>
                <td>@Html.EditorFor(model => model.EG_Photo)</td>
            </tr>
            <tr>
                <td>礼品积分：</td>
                <td>@Html.EditorFor(model => model.EG_Point)</td>
            </tr>
            <tr>
                <td>礼品数量：</td>
                <td>@Html.EditorFor(model => model.EG_Number)</td>
            </tr>
            <tr>
                <td>已兑数量：</td>
                <td>@Html.EditorFor(model => model.EG_ExchangeNum)</td>
            </tr>
            <tr>
                <td>礼品备注：</td>
                <td>@Html.EditorFor(model => model.EG_Remark)</td>
            </tr>

            <tr>
                <td></td>
                <td><input type="button" id="btn_Submit" value="提交" /></td>
            </tr>
        </table>
        @Html.HiddenFor(model => model.EG_ID)
    </fieldset>
}
<script>
    $("#btn_Submit").click(function () {
        var postUrl = "";

        //根据隐藏域id值来判断是添加还是编辑
        if (parseInt($("#EG_ID").val()) > 0) {
            postUrl = "/Gift/Edit";
        }
        else {
            postUrl = "/Gift/Add";
        }

        //ajax表单提交
        $('#from_Gift').form('submit', {
            url: postUrl,
            onSubmit: function () {
                var isValid = $(this).form('validate');
                return isValid;
            },
            success: function (data) {
                var json = JSON.parse(data);
                if (json.State == 1) {
                    window.parent.$.messager.alert('温馨提示', json.Message, 'info');
                    window.parent.$("#dlg").dialog("close");
                    window.parent.$("#Gif").datagrid("reload");
                } else {
                    $.messager.alert('温馨提示', json.Message, 'info');
                }
            }
        })
    })
</script>
